#ecoding: utf-8 -*-
import os,logging

class Proxy:
    pass
    
def addDict(result, two):
    for key, value in two.items():
        result[key] = value

class DictUtils:
    """字典操作工具对象"""
    @staticmethod
    def cursor2dict(curs):
        colnames = [desc[0] for desc in curs.description]
        result = []
        dic = {}
        while True:
            row = curs.fetchone()
            if not row: break
            for (name, value) in zip(colnames, row):
                dic[name] = value
            result.append(dic)
        return result

    @staticmethod
    def cursor2obj(curs):
        colnames = [desc[0] for desc in curs.description]
        result = []
        for row in curs.fetchall():
            proxy = Proxy()
            for (name, value) in zip(colnames, row):
                setattr(proxy, name, value)
            result.append(proxy)
        return result

    @staticmethod
    def dict2obj(dic):
        proxy = Proxy()
        for key, value in dic.items():
            setattr(proxy, key, value)
        return proxy
